﻿#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re, sys, random, unittest

sys.path.append(r"../src/opt/qonso")

from QonsoExtractorUniversalMobile import QonsoExtractorUniversalMobile
from QonsoModel import QonsoModel

class TestExtractorUniversal(unittest.TestCase):
   def setUp(self):
      pass

   def tearDown(self):
      pass

   def test_UniversalMobile(self):
      ex = QonsoExtractorUniversalMobile()
      
      model = QonsoModel()
      ex.SetModel( model )
      f = open(r"data/UniversalMobileBloque.html")
      data = f.read()
      f.close()
      ex.ExtractDatas(data)
      
      self.assertEqual(model.GetConsoVoix('str'), "Il vous reste 27,92&euro;")
      self.assertEqual(model.GetConsoVoix('int'), 27.92)

      self.assertEqual(model.GetReport('int'), 0)
      self.assertEqual(model.GetReport('str'), "Pas de minutes report&eacute;es ce mois ci")
      
      self.assertEqual(model.GetConsoVoixMax('str'), None)
      self.assertEqual(model.GetConsoVoixMax('int'), None)

      self.assertEqual(model.GetConsoVoixSupp('str'), None)
      self.assertEqual(model.GetConsoVoixSupp('int'), None)

      self.assertEqual(model.GetConsoData('int'), 0)
      self.assertEqual(model.GetConsoDataMax('int'), 0)
      
      self.assertEqual(model.GetConsoSMS(), '0')
      self.assertEqual(model.GetConsoSMSMax(), '0')

      self.assertEqual(model.GetConsoHorsForfait(), None)
      self.assertEqual(model.GetDateProchaineFacture(), None)
      
      self.assertEqual(model.GetLastTime(), "Ma consommation au 13/08/2010 &agrave; 10h11")
 #     self.assertEqual(model.GetForfait(), 'Bloqué 24,90€ 1h30 SMS & Internet illimités')
 